#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.Core;
using DynConDevCorp.OpenArch.SmartData.Interfaces;
using DynConDevCorp.OpenArch.SmartData.Interfaces.Attributes;
using DynConDevCorp.OpenArch.SmartData.Interfaces.EventArgClasses;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.Samples.SimpleInvoicing
{
    public class InvoiceLineItem : SmartEntity
    {
        #region Constructors

        public InvoiceLineItem()
        {
        }

        #endregion

        #region Private Instance Methods

        public void CalculateExtendedValue(object sender, ValueChangedEventArgs<decimal> e)
        {
            if ((ExtendedPrice != null) && (Quantity != null) && (UnitPrice != null))
                ExtendedPrice.Value = Quantity.Value*UnitPrice.Value;
        }

        #endregion

        #region Fields and Constants

        [AutoField]
        public ISmartField<decimal> ExtendedPrice { get; private set; } //*{ get; private set; } //* = new SmartField<decimal>();

        [AutoField]
        public ISmartField<Guid> InvoiceID { get; private set; } //* = new SmartField<Guid>();
        [AutoField]
        public ISmartField<Guid> ItemID { get; private set; } //* = new SmartField<Guid>();
        [AutoField]
        public ISmartField<int> LineNumber { get; private set; } //* = new SmartField<int>();
        [AutoField(ValueChanged = "CalculateExtendedValue")]
        public ISmartField<decimal> Quantity { get; private set; } //* = new SmartField<decimal>(/*new RangeValidator(1, 100)*/);
        [AutoField]
        public ISmartField<bool> Taxable { get; private set; } //* = new SmartField<bool>();
        [AutoField(ValueChanged = "CalculateExtendedValue")]
        public ISmartField<decimal> UnitPrice { get; private set; } //* = new SmartField<decimal>(/*new RangeValidator(0.01M, 9999M)*/);
        [AutoField]
        public ISmartField<decimal> Weight { get; private set; } //* = new SmartField<decimal>(/*new RangeValidator(0.1M, 99M)*/);

        #endregion
    }
}